#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 1e6 + 10, INF = 0x3f3f3f3f;

ll n, m;
vector<pair<ll, ll>> a;

void solve()
{
    cin >> n >> m;
    for (ll i = 1;i <= m;i++) {
        ll x, y;cin >> x >> y;
        if (x > n) continue;
        a.push_back({ x,y });
    }
    sort(a.begin(), a.end(), [](pair<ll, ll> a, pair<ll, ll> b) {return a.first - a.second < b.first - b.second;});

    ll sum = n, ans = 0;
    for (ll i = 0;i < a.size();i++) {
        if (sum >= a[i].first) {
            ll w = a[i].first - a[i].second;
            ll t = (sum - a[i].first) / w + 1;
            sum -= t * w;
            ans += t;
        }
    }
    cout << ans;
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}